///*
// * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
// *
// * Licensed under the Apache License, Version 2.0 (the "License");
// * you may not use this file except in compliance with the License.
// * You may obtain a copy of the License at
// *
// *       http://www.apache.org/licenses/LICENSE-2.0
// *
// * Unless required by applicable law or agreed to in writing, software
// * distributed under the License is distributed on an "AS IS" BASIS,
// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// * See the License for the specific language governing permissions and
// * limitations under the License.
// */
//
//package com.fgs.common.update.xupdate;
//
//import androidx.annotation.NonNull;
//
//import com.fgs.common.entity.UpdateData;
//import com.fgs.common.entity.UpdateInfo;
//import com.xuexiang.xupdate.entity.UpdateEntity;
//import com.xuexiang.xupdate.listener.IUpdateParseCallback;
//import com.xuexiang.xupdate.proxy.IUpdateParser;
//import com.xuexiang.xutil.net.JsonUtil;
//
///**
// * 自定义更新解析器
// *
// * @author xuexiang
// * @since 2018/7/12 下午3:46
// */
//public class CustomUpdateParser implements IUpdateParser {
//    @Override
//    public UpdateEntity parseJson(String json) throws Exception {
//        return getParseResult(json);
//    }
//
//    private UpdateEntity getParseResult(String json) {
//        UpdateData result = JsonUtil.fromJson(json, UpdateData.class);
//        if (result != null) {
//            UpdateInfo info = result.data;
//            if (info != null) {
//                boolean hasUpdate = info.needUpdate == 2;
////                boolean isIgnorable = info.needUpdate == 1;
//                boolean isForce = info.needUpdate == 2;
//                String versionName = info.latestVersion;
//                String updateLog = info.description;
//                String apkUrl = info.download;
//
//                return new UpdateEntity()
//                        .setHasUpdate(hasUpdate)
////                        .setIsIgnorable(isIgnorable)
//                        .setVersionName(versionName)
//                        .setUpdateContent(updateLog)
//                        .setDownloadUrl(apkUrl)
//                        .setForce(isForce);
//            }
//        }
//        return null;
//    }
//
//    @Override
//    public void parseJson(String json, @NonNull IUpdateParseCallback callback) throws Exception {
//        //当isAsyncParser为 true时调用该方法, 所以当isAsyncParser为false可以不实现
//        callback.onParseResult(getParseResult(json));
//    }
//
//
//    @Override
//    public boolean isAsyncParser() {
//        return false;
//    }
//}
